package com.css.fxfzcpxx.modules.categoryView.controller;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzcpxx.base.response.RestResponse;
import com.css.fxfzcpxx.modules.categoryView.param.QueParam;
import com.css.fxfzcpxx.modules.categoryView.service.CategoryViewService;
import com.css.fxfzcpxx.modules.categoryView.vo.CategoryViewVo;
import com.css.fxfzcpxx.util.PlatformPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/categoryView")
@Slf4j
public class CategoryViewController {
    @Autowired
    CategoryViewService categoryViewService;

    /***
     * 分页查询
     * @param
     * @return
     */
    @GetMapping("/getPage")
    public RestResponse getPage(HttpServletRequest request, QueParam queParam){
        RestResponse restResponse=null;
        try {
            int curPage = Integer.valueOf(request.getParameter(PlatformPageUtils.CUR_PAGE));
            int pageSize = Integer.valueOf(request.getParameter(PlatformPageUtils.PAGE_SIZE));
            Map<String,Object> list=categoryViewService.getPage(queParam,curPage,pageSize);



            restResponse= RestResponse.succeed(list);
        }catch (Exception e){
            String errormessage="查看失败";
            log.error(errormessage,e);
            restResponse=RestResponse.fail(errormessage);
        }
        return restResponse;
    }


}
